# Maintainer: Dominic Sisneros <dsisnero@gmail.com>

_realname=mruby
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.1.0
pkgrel=1
pkgdesc="mruby is the lightweight implementation of the Ruby language (mingw-w64)"
arch=('any')
url="https://github.com/mruby"
license=('MIT')
makedepends=("${MINGW_PACKAGE_PREFIX}-ruby"
             "bison")
source=(${_realname}-${pkgver}.zip::"https://github.com/${_realname}/${_realname}/archive/${pkgver}.zip")
sha256sums=('3fae772669e1b09885d0bb59be57964e2c0c3f5c32c5e9f2dcbb0ed2bb532782')

build() {
  [[ -d ${srcdir}/build-${MINGW_CHOST} ]] && rm -rf ${srcdir}/build-${MINGW_CHOST}
  cp -rf "${srcdir}/${_realname}-${pkgver}" ${srcdir}/build-${MINGW_CHOST}
  cd ${srcdir}/build-${MINGW_CHOST}

  ./minirake
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  install -d "${pkgdir}${MINGW_PREFIX}"/bin
  cp build/host-debug/bin/* "${pkgdir}${MINGW_PREFIX}"/bin/ || return 1
  cp build/host/bin/* "${pkgdir}${MINGW_PREFIX}"/bin/ || return 1

  install -d "${pkgdir}${MINGW_PREFIX}"/lib
  cp build/host/lib/*.a "${pkgdir}${MINGW_PREFIX}"/lib/

  install -d "${pkgdir}${MINGW_PREFIX}"/include
  cp -r include/* "${pkgdir}${MINGW_PREFIX}"/include/
}
